// DataCacheManager.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "DataCacheManager.h"
#include "SegmentCache.h"
#include "../LibCommon/memrec.h"
#define new DBG_NEW

#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
    return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif
DATACACHEMANAGER_API IDataCacheManager * CreateDataCacheManager(const char * strWho)
{
	tContentCacheMgr * pMgr = new tContentCacheMgr();
	if (pMgr)
	{
		IDataCacheManager * pIDCM = NULL;
		if (pMgr->GetInterface(eIID_DataCacheManager, (void**)&pIDCM, strWho) == RET_OK)
			return pIDCM;
		else
		{
			delete pMgr;
			return NULL;
		}
	}
	return NULL;
}

DATACACHEMANAGER_API void DeleteDataCacheManager(IDataCacheManager* pDCM, const char * strWho)
{
	pDCM->Release(strWho);
	delete (tContentCacheMgr*)pDCM;
}

DATACACHEMANAGER_API ITVCacheManager * CreateTVCacheManager(const char * strWho)
{
	tTVCacheManager * pTVMgr = new tTVCacheManager();
	if (pTVMgr)
	{
		ITVCacheManager * pTVCM = NULL;
		if (pTVMgr->GetInterface(eIID_TVCacheManager, (void**)&pTVCM, strWho) == RET_OK)
		{
			return pTVCM;
		}
		else
		{
			delete pTVMgr;
			return NULL;
		}
	}
	return NULL;
}

DATACACHEMANAGER_API void DeleteTVCacheManager(ITVCacheManager * pTVCM, const char * strWho)
{
	pTVCM->Release(strWho);
	delete (tTVCacheManager*)pTVCM;
}

